<div class="opwindow">
	<form name="theform2" id="theform2" method="post" action="{echo \befen\get_url()}">
	<div class="layui-form layui-row">
		<div class="layui-form-item">
			<div class="layui-col layui-col-md6">
				<label>所属商户</label>
				<div class="layui-input-inline" style="width:100%;">
					<input type="text" name="merchant_name" id="merchant_name" class="layui-input" value="" placeholder="请选择商户">
				</div>
			</div>
			<div class="layui-col layui-col-md6">
				<label>所属门店</label>
				<div class="layui-input-inline" style="width:100%;">
					<input type="text" name="store_name" id="store_name" class="layui-input" value="" placeholder="请选择门店">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col layui-col-md6">
				<label>设备类型</label>
				<select name="trade_gate" id="trade_gate" class="layui-select">
					<option value="weixin" <!--{if $value['trade_gate'] == 'weixin'}-->selected<!--{/if}-->>微信</option>
					<option value="alipay" <!--{if $value['trade_gate'] == 'alipay'}-->selected<!--{/if}-->>支付宝</option>
				</select>
			</div>
			<div class="layui-col layui-col-md6">
				<label>设备状态</label>
				<select name="status" id="status" class="layui-select">
					<!--{loop model('StoreDevice')->getStatus() $key $val}-->
					<option value="{$key}" <!--{if $key == 1}-->selected<!--{/if}-->>{$val}</option>
					<!--{/loop}-->
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col layui-col-md12">
				<label>SN</label>
				<input type="text" name="SN" id="SN" class="layui-input layui-input-wdith" value="{$value[SN]}" placeholder="请输入设备SN">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col layui-col-md12" style="text-align:right;">
				<button type="submit" name="submit2" value="submit2" id="submit2" class="layui-btn">提交</button>
			</div>
		</div>
	</div>
	</form>
</div>
<script type="text/javascript">
init_Form();
$("#theform2").find("#SN").attr("disabled", "disabled").addClass("layui-disabled");
$("#submit2").click(function(){
	if($("#theform2 input[name=merchant_id]").val() == "") {
		showTips("#theform2 #merchant_name", $("#theform2 #merchant_name").attr("placeholder"));
		return false;
	}
	if($("#theform2 #SN").val() == "") {
		showTips("#theform2 #SN", $("#theform2 #SN").attr("placeholder"));
		return false;
	}
	ajaxSubmit(this, "", "#theform2");
});
window.op_store = $('#theform2 input[name=store_name]').autoComplete({
	url: "{echo url('store/index')}",
	field: "",
	value: "",
	name_hidden: "store_id",
	value_hidden: "",
});
$('#theform2 input[name=merchant_name]').autoComplete({
	url: "{echo url('merchant/index')}",
	field: "",
	value: "",
	name_hidden: "merchant_id",
	value_hidden: "",
}, function(o, _self, _target){
	window.op_store.url = '{echo url('store/index')}?merchant_id=' + _target.val();
});
$('#theform2 input[name=merchant_name]').bind("input propertychange", function(){
	window.op_store._self.val("");
	window.op_store.name_hidden && window.op_store._target.val("");
});
</script>
